import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-13
 * Time: 9:32
 */
class Student{
    int age;

    public Student(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                '}';
    }
}
public class Test {
    //字符合法
    public static boolean isLefalChar(char ch){
        if(ch>='a'&&ch<='z'||ch>='0'&&ch<='9'){
            return true;
        }else {
            return false;
        }
    }
    public static boolean isPalindrome(String s) {
        //全部变成小写
        s = s.toLowerCase();
        int left = 0;
        int right = s.length()-1;
        //开始查找
       while (left<right){
           //跳过左边非法的字符
           while(left<right && !isLefalChar(s.charAt(left)) /*当字符合法时！返回false，跳出循环体*/){
               left++;
           }
           //跳过右边非法的字符
           while(left<right && !isLefalChar(s.charAt(right))){
               right--;
           }
         if (s.charAt(left)!=s.charAt(right)){
            return false;
           }else{
             left++;
             right--;
         }
       }
       return true;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        isPalindrome(s);

    }
    public static void main22(String[] args) {
        String s1 = "    abac   jkj   lklj    ";
        String s = s1.trim();
        System.out.println(s1);
        System.out.println("========");
        System.out.println(s);
    }
    public static void main21(String[] args) {
        String s1 = "abcdef";
        String s = s1.substring(1,4);//从b开始截取到e结束
        System.out.println(s);//bcd
    }
    public static void main20(String[] args) {
        String s1 = "name=Jack&from=China";
        String[] ss = s1.split("&");
        for (String s: ss) {
            //ss[0]=name=Jack
            //ss[1]=from=China
            //System.out.println(ss);
            String[] ret = s.split("=");
            for (String s2: ret) {
                System.out.println(s2);
            }
        }
    }
    public static void main19(String[] args) {
        String s1 = "Chinese&Li hello";
        String[] ss = s1.split("&| ");//根据多个符号拆分用|来隔开
        for (String s: ss) {
            System.out.println(s);
        }
    }

    public static void main18(String[] args){
        int[] count =new int[26];
        Scanner in = new Scanner(System.in);
        while(in.hasNextLine()){
            String s1 = in.nextLine();
            for(int i = 0; i<s1.length();i++){
                char ch = s1.charAt(i);
                count[ch-97]++;
            }
            for(int i = 0; i<s1.length();i++){
                char ch = s1.charAt(i);
               if(  count[ch-97]!=0){
                   System.out.print(ch);
                   count[ch-97]=0;
               }
            }
//            for(int i = 0; i<26;i++){
//                if(count[i] != 0){
//                    char ch  = (char)(i+97);
//                    System.out.print(ch);
//                }
//            }
        }
    }
        public static void main17(String[] args){
            int[] count =new int[26];
            Scanner in = new Scanner(System.in);
            while(in.hasNextLine()){
                String s1 = in.nextLine();
                for(int i = 0; i<s1.length();i++){
                    char ch = s1.charAt(i);
                    count[ch-97]++;
                }
                for(int i = 0; i<26;i++){
                    if(count[i] != 0){
                        char ch  = (char)(i+97);
                        System.out.print(ch);
                    }
                }
            }
        }

    public static void main16(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()){
//            String s = scanner.nextLine();
//        }
        char ch = 97+0;
        System.out.println(ch);
    }
    public static void main15(String[] args) {
        String s1 = "192\\168\\2\\5";
        String[] ss1 = s1.split("\\\\");
        for (String s: ss1) {
            System.out.println(s);//打印不出结果
        }
    }
    public static void main14(String[] args) {
        String s1 = "hello welcome to my homepage";
        String[] ss1 = s1.split(" ",3);
        for (String s: ss1) {
            System.out.println(s);
        }
    }
    public static void main13(String[] args) {
        String s1 = "aababcabcdabcde";
        String ss = s1.replaceFirst("ab","TO");// 只把第一个ab都替换成TO
        System.out.println(ss);//aTOabcabcdabcde
        System.out.println("s1->"+s1);//s1->aababcabcdabcde

    }
    public static void main12(String[] args) {
        String s1 = "aababcabcdabcde";
        String ss = s1.replace('a','O');// 所有a都替换成O
        System.out.println(ss);//OObObcObcdObcde
        System.out.println("s1->"+s1);//s1->aababcabcdabcde s1本身没有改变，而是产生了新的对象
    }
    public static void main11(String[] args) {
        String s = String.format("%d-%d-%d", 2019, 9,14);
        System.out.println(s);
    }
    public static void main10(String[] args) {
        char[] chars = {'h','e','l','l','o'};
        String s1 = new String(chars);
        System.out.println(s1);
    }
    public static void main9(String[] args) {
        String s1 = "hello";
        char[] chars = s1.toCharArray();
        for (char ch:chars) {
            System.out.println(ch);
        }
        System.out.println(s1);
    }
    public static void main8(String[] args) {
        String s1 = "hello";
        String s2 = "World";
        String ss1 = s1.toUpperCase();
        String ss2 = s2.toLowerCase();
        System.out.println(ss1);//HELLO
        System.out.println(ss2);//world
        //s1、s2的值本身没有改变
        System.out.println(s1);//hello
        System.out.println(s2);//World
    }
    public static void main7(String[] args) {
        int a = Integer.parseInt("12");
        System.out.println(a);//12
        int b = Integer.parseInt("100",8);
        System.out.println(b);//64
        int c = Integer.parseInt("100");
        System.out.println(c);//100
    }
    public static void main6(String[] args) {
        int a = Integer.valueOf("12");
        System.out.println(a);//12
        int b = Integer.valueOf("100",8);//64 八进制：1*8^2+0*8^1+0*8^0==64
        System.out.println(b);
        int c = Integer.valueOf("100");//默认十进制
        System.out.println(c);//100
    }
    public static void main5(String[] args) {
        String s1 = String.valueOf(new Student(18));
        System.out.println(s1);//Student{age=18}
    }
    public static void main4(String[] args) {
        String s1 = String.valueOf(123);
        String s2 = String.valueOf(3.14);
        System.out.println(s1);//123
        System.out.println(s2);//3.14
    }
    public static void main3(String[] args) {
        String s1 = "ababacd";
        String s2 = "文件名.mp3";
        int p = s2.lastIndexOf('.');//3 '.'前的内容为文件名
        int pos = s1.lastIndexOf('a',3);// 从3开始找，从后往前找
        System.out.println(pos);//2
        System.out.println(p);
    }
    public static void main2(String[] args) {
        String s1 = "ababcabcde";
        int pos = s1.indexOf("ab",2);
        System.out.println(pos);//2 从下标2处开始查找ab
        pos = s1.indexOf("bc",4);
        System.out.println(pos);//6  从下标6处开始查找bc
    }
    public static void main1(String[] args) {
        String s1 = "hello";
        for (int i = 0; i < s1.length(); i++) {
            char ch = s1.charAt(i);
            System.out.print(ch+" ");
        }
        System.out.println("=======");
        int pos = s1.indexOf('d',4);//从4下标开始查找'd'
        System.out.println(pos);//找不到 -1
    }
}
